package kylintool.arraylist;

import java.util.ArrayList;
import java.util.List;

public class ArrayListThreadSafe {
	private static List<Integer> ilist = new ArrayList<>();
	public static void main(String[] args) {
		Thread t1 = new Thread(new ArrayListThreadSafe().new Arraylisttt(0));
		Thread t2 = new Thread(new ArrayListThreadSafe().new Arraylisttt(1));
		t1.start();
		t2.start();
//		System.out.println(ilist.size());
	}
	class Arraylisttt implements Runnable{
		int startnum = 0;
		Arraylisttt(int startnum){
			this.startnum = startnum;
		}
		@Override
		public void run() {
			for(int i=0;i<10000000;i++){
				this.startnum+=2;
				ilist.add(this.startnum);
			}
			System.out.println(this.startnum);
			
		}
		
	}
	
}


